package com.qfedu.mbti.controller;

import com.qfedu.mbti.config.SystemConfig;
import com.qfedu.mbti.param.QuestionAnswer;
import com.qfedu.mbti.service.MbtiQuestionService;
import com.qfedu.mbti.vo.R;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * mbti测试题表(MbtiQuestion)表控制层
 *
 * @author makejava
 * @since 2024-11-04 11:43:41
 */
@RestController
@RequestMapping("api/question")
@Tag(name = "测试题模块")
@CrossOrigin
public class MbtiQuestionController {
    /**
     * 服务对象
     */
    @Resource
    private MbtiQuestionService service;

    @Operation(summary = "回答问题")
    @PostMapping("answer")
    public R answer(@RequestBody QuestionAnswer answer){
        return service.answerQuestion(answer);
    }

    @Operation(summary = "查询问题")
    @GetMapping("all")
    public R all(Integer meid){
        return service.queryByMeid(meid);
    }

    @Operation(summary = "我的测试题")
    @GetMapping("myquestion")
    public R myQuestion(HttpServletRequest request){
        return service.queryByUid(request.getHeader(SystemConfig.HEADER_TOKEN));
    }

}